var status = -1;

function action(e, c, b) {
    var a = cm.getMapId() - 744000000;
    if (a < 0 || a > 16) {
        cm.dispose();
        return
    }
    if (status == 0 && e == 0) {
        cm.dispose();
        return
    }
    status++;
    if (status == 0) {
        var f = eim.getProperty("map_" + a);
        if (f != null && f.equals("clear")) {
            cm.sendOk("你已经通过这里的考核了。去下一间教室吧。");
            cm.dispose()
        } else {
            cm.sendOk("误理力……不是，物理实力还不错。\r\n\r\n今天历史课就上到这里。")
        }
    } else {
        if (status == 1) {
            var d = Math.min(15, eim.getNumberProperty("state"));
            cm.fieldEffect_ScreenMsg("Map/Effect.img/MapleHighSchool/clear");
            cm.gainExp(1000 * d * cm.getPlayer().getLevel());
            cm.gainItem(4310105, parseInt(d * cm.getPlayer().getLevel() / 10));
            eim.setProperty("map_" + a, "clear");
            cm.dispose()
        } else {
            cm.dispose()
        }
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function start() {
    status = -1;
    action(1, 0, 0)
};